﻿@using Ext.Net
@model VinhSon.Intranet.Models.RoleModel
@{
    ViewBag.Title = "Add Role";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section script
{
    <script type="text/javascript">
        function submitForm() {
            if (window.App.FormPanel1.getForm().isValid())
                request('@Url.Action("Add")', window.App.FormPanel1.getValue(), function(result) {
                    showNotification(window.parent, result, function() {
                        window.parent.App.gvData.getStore().reload();
                        window.parent.App.winAdd.close();
                    });
                }, function() {
                    window.Ext.Msg.show(
                        {
                            title: "Confirm",
                            buttons: window.Ext.Msg.YES,
                            fn: function() {
                                window.parent.App.winAdd.close();
                            },
                            icon: window.Ext.Msg.ERROR,
                            msg: "There some errors occour when update. Please try again later."
                        });
                });
        }
    </script>
}
@(Html.X()
     .FormPanel()
     .ID("FormPanel1")
     .Method(HttpMethod.POST)
     .BodyPadding(10)
     .Border(false)
     .Title("Add Role")
     .Items(form =>
                {
                    form.Add(Html.X()
                                 .TextFieldFor(c => c.Name)
                                 .FieldLabel("Name")
                                 .AllowBlank(false)
                                 .EmptyText("Name"));
                    form.Add(Html.X()
                                 .TextAreaFor(c => c.Description)
                                 .FieldLabel("Description")
                                 .Width(420)
                                 .EmptyText("Description"));
                    form.Add(Html.X()
                                 .Button()
                                 .FormBind(true)
                                 .Text("Add New")
                                 .MarginSpec("0 5 0 100")
                                 .OnClientClick("submitForm"));
                    form.Add(Html.X()
                                 .Button()
                                 .Text("Cancel")
                                 .OnClientClick("window.parent.App.winAdd.close();"));
                }))